package cn.kattomy.shop.categorysecond.service.impl;

import java.util.List;

import cn.kattomy.shop.categorysecond.dao.CategorySecondDao;
import cn.kattomy.shop.categorysecond.service.CategorySecondService;
import cn.kattomy.shop.categorysecond.vo.CategorySecond;
import cn.kattomy.shop.product.vo.Product;
import cn.kattomy.shop.utils.PageBean;

public class CategorySecondServiceImpl implements CategorySecondService {
	
	private CategorySecondDao categorySecondDao;
	
	public void setCategorySecondDao(CategorySecondDao categorySecondDao) {
		this.categorySecondDao = categorySecondDao;
	}

	@Override
	public PageBean<CategorySecond> findByPage(Integer pageNo) {
		int pageSize = 10;
		PageBean<CategorySecond> pageBean = new PageBean<>(pageNo, pageSize);
		//设置总的记录数
		int totalItemNo = categorySecondDao.findCount();
		pageBean.setTotalItemNo(totalItemNo);
		//设置每页显示的数据的集合
		int begin = (pageNo - 1)* pageSize;
		List<CategorySecond> csList = categorySecondDao.findByPageNo(begin, pageSize);
		pageBean.setList(csList);
		return pageBean;
	}

	@Override
	public void save(CategorySecond categorysecond) {
		categorySecondDao.save(categorysecond);
	}

	@Override
	public void delete(CategorySecond categorysecond) {
		categorySecondDao.delete(categorysecond);
	}

	@Override
	public CategorySecond findByCsid(Integer csid) {
		return categorySecondDao.findByCsid(csid);
	}

	@Override
	public void update(CategorySecond categorySecond) {
		categorySecondDao.update(categorySecond);
	}

	@Override
	public List<CategorySecond> findAll() {
		return categorySecondDao.findAll(); 
	}


}
